<!DOCTYPE html>
<html>
<head>
    <title>我的结伴</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/userTravels.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/checkLogin.js"></script>
    <script src="/js/common.js"></script>

    <script>
        $(function () {
            var currentPage = 1;
            var travelsDate = [];
            var pages;
            var flag = false;//表示当前没有在查询
            function loadTravels() {
                if (flag) {
                    return;
                }
                flag = true;
                console.log(user.id);
                $.get(baseUrl+"/users/" + user.id + "/companions", {currentPage: currentPage}, function (data) {
                    console.log(data);
                    $.merge(travelsDate, data.list);
                    var ret = {"list": travelsDate};
                    $(".companions").renderValues(ret, {
                        getHref: getHref
                    });
                    currentPage++;
                    pages = data.pages;
                    flag = false;//表示查询完成
                });
            }

            loadTravels();

            $(window).scroll(function () {
                if ($(window).height() + $(document).scrollTop() + 1 >= $(document).height()) {
                    if (pages >= currentPage) {
                        loadTravels();

                    } else {
                        $(document).dialog({
                            type: 'notice',
                            infoText: '亲,到底了',
                            autoClose: 2000,
                            position: 'bottom'
                        });
                    }
                }
            });
        })
    </script>
</head>

<body style="background: url('/upload/2.bmp')">
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="/companion.html">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>我的结伴</span>
        </div>
        <div class="col"></div>
    </div>
</div>


<div class="container companions">
    <dl class="list" render-loop="list">
        <dd>
            <a data-url="/mine/editCompanions.html?id=" render-key="list.id" render-fun="getHref">
                <img render-src="list.coverUrl">
                <h6 class="title" render-html="list.title"></h6>
                <p>发布时间 <span render-html="list.createTime"></span>
                    <!--<span class="span-right">-->
                    <!--<i class="fa fa-heart"></i><span>0</span>收藏-->
                    <!--<i class="fa fa-thumbs-o-up"></i><span>0</span>点赞</span>-->
                </p>
            </a>
        </dd>

    </dl>
</div>


</body>
</html>
